Skip to content

Replace KeyboardShortcuts with our own global shortcuts - #13

Merged
vpetersson-bot merged 1 commit into
masterfrom
own-hotkeys
Nov 19, 2026
Merged

vpetersson-bot merged 1 commit into
masterfrom
own-hotkeys

Conversation

@vpetersson-bot

Copy link
Copy Markdown
Collaborator

Removes KeyboardShortcuts, Blotter's only third-party dependency, and replaces it with a small implementation of our own. The behaviour is the same: six optional global shortcuts, recorded in Settings › Shortcuts and shown in the menu bar menu.

How it works

  • KeyCombo and HotkeyAction (BlotterKit, tested): a key code plus modifiers. Handles conversion to Carbon modifiers, the ⌃⌥⇧⌘ symbols, validity (⌘, ⌥ or ⌃ is required, except for F-keys), names for special keys, conflicts between actions, and converting Blotter 2's ShortcutRecorder values.
  • HotkeyCenter: registers shortcuts with Carbon's RegisterEventHotKey, the same API KeyboardShortcuts used underneath. It's the only one that delivers system-wide shortcuts to a sandboxed app without asking for Accessibility access. Registration failures, e.g. a shortcut already taken by another app, are logged. Shortcuts are paused while one is being recorded, so pressing an existing one records it instead of firing it.
  • HotkeyStore: keeps shortcuts as JSON in user defaults under Hotkey.<action>. Before a shortcut is assigned it checks for missing modifiers, conflicts with another Blotter action, and shortcuts macOS reserves (CopySymbolicHotKeys).
  • KeyDisplay: shows a key as it appears on the current keyboard layout (UCKeyTranslate). It falls back to an ASCII-capable layout for input methods without one, and builds NSMenuItem key equivalents.
  • ShortcutRecorder: a SwiftUI field. Click it, then press the shortcut; Escape cancels and Delete clears. There is a clear button, inline error messages and VoiceOver labels.
  • Blotter 2 migration: now decodes straight into HotkeyStore.

Housekeeping

  • Package removed: Package.resolved is gone, since there are no remote packages left.
  • Translations: eight new strings, translated into all seven languages.
  • Screenshots: CI now also captures the Shortcuts pane. -BlotterSettingsPane <n> opens a given pane at launch.
  • Tests:
    • BlotterKit: 54 tests, 8 of them new for KeyCombo.
    • App: HotkeyStore persistence, validation, and 2.x shortcut migration.

No data migration is needed for 3.0 users, because 3.0 hasn't shipped.

Not verifiable on CI

Pressing a global shortcut and recording one with the keyboard can't be done on CI. The same goes for how keys display on non-US layouts. Please check these on a Mac.

🤖 Generated with Claude Code

Removes the only third-party dependency.

- BlotterKit: KeyCombo (key code and modifiers, Carbon conversion,
  symbols, validity, Blotter 2 conversion) and HotkeyAction, with tests.
- HotkeyCenter registers shortcuts with Carbon's RegisterEventHotKey,
  the only API that delivers system-wide shortcuts to a sandboxed app
  without Accessibility access, and pauses them while one is recorded.
- HotkeyStore persists them as JSON in user defaults and checks for
  missing modifiers, conflicts with other actions and shortcuts macOS
  reserves.
- KeyDisplay names keys for the current keyboard layout (UCKeyTranslate)
  and builds menu key equivalents.
- ShortcutRecorder replaces the recorder in Settings: click, press the
  shortcut; Escape cancels and Delete clears.
- The Blotter 2 migration writes into the new store.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vpetersson-bot
vpetersson-bot merged commit 7a2c865 into master Nov 19, 2026
2 checks passed
@vpetersson-bot
vpetersson-bot deleted the own-hotkeys branch November 19, 2026 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant